package com.ms.demo;

/**
 * 我们将创建一个 Shape 接口和实现了 Shape 接口的实体类。然后我们创建一个实现了 Shape 接口的抽象装饰类 ShapeDecorator，并把 Shape 对象作为它的实例变量。
 * RedShapeDecorator 是实现了 ShapeDecorator 的实体类。
 * DecoratorPatternDemo 类使用 RedShapeDecorator 来装饰 Shape 对象。
 * @author: ms
 * @create: 2022-10-26 10:05
 */
public class TestMain {

    public static void main(String[] args) {
        //Shape circle = new Circle();
        //System.out.println("Circle with normal border");
        //circle.draw();
        //使用red装饰器
        ShapeDecorator redCircle = new RedShapeDecorator(new Circle());
        ShapeDecorator redRectangle = new RedShapeDecorator(new Rectangle());

        System.out.println("Circle of red border");
        redCircle.draw();

        System.out.println("Rectangle of red border");
        redRectangle.draw();

        System.out.println("---------------------------------------------");

        ShapeDecorator greenCircle = new GreenShapeDecorator(new Circle());
        ShapeDecorator greenRectangle = new GreenShapeDecorator(new Rectangle());

        System.out.println("Circle of green border");
        greenCircle.draw();

        System.out.println("Rectangle of green border");
        greenRectangle.draw();
    }
}